$(document).ready(function (){
	sessionUrl();
	showsession();
	
	
	initpost();
/* 	$('.uploadhead').click(function(){
		showMistAndWait();
	}); */
});


//图片上传函数
function uploadhead(file){
	var files  = $('.uploadhead').prop('files');
	var reader = new FileReader();
	reader.readAsDataURL(files[0]);
	reader.onload = function(e){
		var imgsrc = e.target.result;
		showMistAndWait();
		$.ajax({
			type:'post',
			url:'../actions/userAction.php',
			data:{
				act			:'uploadhead',
				imgsrc		:imgsrc,
				//imgid		:imgid
			}, 
			async: true,	
			beforeSend: function(){
				showMistAndWait();
			},
			success:function(data){
				console.log(data);
				$('.userHeadIcon').attr('src',imgsrc);
				//previewB(imgid,data);
				alert('头像上传成功！');
				hideMistAndWait();
			}
		});  
				
	}
}

//初始化函数，将userid下的tmp文件夹下的文件情况
function initpost(){
	$.ajax({
		type:'post',
		url:'../actions/c2cAction.php',
		data:{
			act	:'initpost',
		}, 
		async: true,	
		beforeSend: function(){
			//showMistAndWait();
		},
		success:function(data){
			//hideMistAndWait();
			console.log(data);
			//alert(data);
		}
	});   
}

